package com.ruoyi.aitcommon.vo;

import lombok.Data;

@Data
public class PageInfoVO {
    private int pageSize = Integer.MAX_VALUE; // 默认值设置在字段声明处
    private int pageNum = 1; // 默认值设置在字段声明处,pageNum从1开始
    private long totalNum;
    private int totalPage;
    private int curPageSize;

    public void setTotalNum(long totalNum) {
        this.totalNum = totalNum;
        if (this.pageSize > 0) {
            // 计算整体页数,向上取整
            this.totalPage = (int) Math.ceil((double) this.totalNum / this.pageSize);

            if (pageNum == totalPage) {
                //当前页数等于最后一页
                this.curPageSize = (int) (totalNum % pageSize == 0 ? pageSize : totalNum % pageSize);
            } else if(pageNum<totalPage&&pageNum>0) {
                //当前页数小于总页数
                this.curPageSize = pageSize;
            } else{
                //当前页数大于总页数
                this.curPageSize=0;
            }
        }
    }
}
